package com.hzeport.bgs22emduty.inbound.api;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hzeport.bgs22emduty.config.login.LoginCompoentService;
import com.hzeport.bgs22emduty.config.login.UserInfoDetailVO;
import com.hzeport.bgs22emduty.entity.ParamScheduleSetting;
import com.hzeport.bgs22emduty.service.ParamLeaderService;
import com.hzeport.bgs22emduty.service.ParamScheduleSettingService;
import com.hzeport.bgs22emduty.vo.ParamDuty.DutyTimeVO;
import com.hzeport.bgs22emduty.vo.ParamLeader.ParamLeaderListVO;
import com.hzeport.bgs22emduty.vo.ParamScheduleSetting.ParamScheduleSettingVO;
import com.hzeport.bgs22emduty.vo.base.PageVO;
import com.hzeport.bgs22emduty.common.base.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/paramScheduleSetting")
@Api(value = "paramScheduleSetting", tags = "排班配置")
@Slf4j
public class ParamScheduleSettingController {

    @Resource
    private ParamScheduleSettingService paramScheduleSettingService;
    @Resource
    private LoginCompoentService loginCompoentService;

    @ApiOperation(value = "获取时间段")
    @GetMapping(value = "getDutyTime")
    public BaseResult<List<DutyTimeVO>> getDutyTime() {
        UserInfoDetailVO userInfo = loginCompoentService.getUserInfo();
        return paramScheduleSettingService.getDutyTime(userInfo);
    }

    @ApiOperation(value = "获取时间段已选择")
    @PostMapping(value = "getDutyTime")
    public BaseResult<List<String>> getDutyTimeIds(@RequestParam String code) {
        UserInfoDetailVO userInfo = loginCompoentService.getUserInfo();
        return paramScheduleSettingService.getDutyTimeIds(userInfo,code);
    }

    @ApiOperation(value = "列表")
    @PostMapping(value = "getPage")
    public BaseResult<Page<ParamScheduleSetting>> getPage(@RequestBody PageVO pageVO) {
        UserInfoDetailVO userInfo = loginCompoentService.getUserInfo();
        return paramScheduleSettingService.getPage(userInfo,pageVO);
    }

    @ApiOperation(value = "添加")
    @PostMapping(value = "save")
    public BaseResult<String> save(@RequestBody ParamScheduleSettingVO paramScheduleSetting) {
        UserInfoDetailVO userInfo = loginCompoentService.getUserInfo();
        return paramScheduleSettingService.save(userInfo,paramScheduleSetting);
    }

    @ApiOperation(value = "删除")
    @PostMapping(value = "del")
    public BaseResult<String> del(@RequestParam String id) {
        paramScheduleSettingService.removeById(id);
        return BaseResult.ok(null,"删除成功");
    }

}
